<!-- 订单 -->
<template>
  <div class="about-container">
    <div class="main">
      <div class="mainlist" v-if="details&&details.length">
        <div class="listmain" v-show="orderListshow">
          <div class="orderstatus">{{orderList.status}}
           <van-icon class='cross' name="cross" @click="headleBackorder" />
          </div>
          <div class="order_address">
            <div class="left">
              <img :src="postions" alt="">
            </div>

            <div class="right">
              <div class="info">
                <div class="name">{{orderList.receiverName}}</div>~
                <div class="tel">{{orderList.bookerPhone}}</div>
              </div>
              <div class="address">{{orderList.receiverAddress}}</div>
            </div>
          </div>
          <div class="order_main">
            <ul class="cakelist">
              <li v-for="child in orderList.details" :key="child.id">
                <img :src="child.imgUrl" class="cakeimg" alt="">
                <div class="cakename">{{ child.marketName }}</div>
              </li>
            </ul>
            <div class="order_info">
              <div class="order-item">
                <span class="title">祝福语</span>
                <span>{{orderList.blessings}}</span>
              </div>
              <div class="order-item">
                <span class="title">配送时间</span>
                <span style="text-align: right;font-size: 12px;">{{orderList.deliveryStartTime}}→{{orderList.deliveryEndTime}}</span>
              </div>
              <div class="order-item">
                <span class="title">备注</span>
                <span>{{orderList.consumerRemark}}</span>
              </div>
              <div class="line"></div>
              <div class="order-item">
                <span class="title odernum">订单号</span>
                <div>
                  <span class="copyObj" style="padding-right:8px">{{orderList.xmbzNo}}</span>
                  <span class="ordernum_read" @click="headerCopy(orderList.xmbzNo)">复制</span>
                </div>
              </div>
              <div class="order-item">
                <span class="title orderTime">下单时间</span>
                <span>{{orderList.orderTime}}</span>
              </div>
            </div>
          </div>
        </div>
        <div class="bottom">
          <div>熊猫不走·蛋糕</div>
          <concatService></concatService>
        </div>
      </div>
      <div class="mainlist" v-else>
        <div class="nodata" v-show="orderListnoshow">
          <img :src="nolist" alt="">
          <p class="tips">未查到订单记录</p>
        </div>
        <div class="bottomNodata">
          <div>熊猫不走·蛋糕</div>
          <concatService></concatService>
        </div>
      </div>
    </div>

  </div>
</template>
<script>
  import nolist from '@/assets/image/list_no.png'
  import postions from '@/assets/image/postions.png'
  import {
    getOrderById
  } from '@/api/index'
  export default {
    props:{
      xmbzNos:String
    },
    watch: {
      xmbzNos: {
        immediate: true, // 这句重要
        handler(val) {
          console.log(val,'val')
          setTimeout(() => {
            getOrderById({orderId:val}).then(res => {
              this.orderList = res.data
              this.details = res.data.details
              if (this.details && this.details.length > 0) {
                this.orderListnoshow = false
                this.orderListshow = true
              } else {
                this.orderListnoshow = true
                this.orderListshow = false
              }
            })
          }, 1000)
        }
      },
     },
    data() {
      return {
        nolist,
        postions,
        input: '',
        details: '',
        orderList: '',
        orderListshow: false,
        orderListnoshow: true,
        docmHeight: document.documentElement.clientHeight, // 默认屏幕高度
        showHeight: document.documentElement.clientHeight, // 实时屏幕高度
        hidShow: false, //
        loginshow: false, // 登录弹窗
        tel: '15735163761',
        style: false,
        yzmstyle: false,
        buttonText: "发送验证码",
        isDisabled: false, // 是否禁止点击发送验证码按钮
        flag: true,
        smscode: '',
      }
    },
    watch: {
      showHeight: function() {
        if (this.docmHeight > this.showHeight) {
          this.hidShow = false;
        } else {
          this.hidShow = true;
        }
      }
    },
    mounted() {
      getOrderById({orderId:this.xmbzNos}).then(res => {
        this.orderList = res.data
        this.details = res.data.details
        if (this.details && this.details.length > 0) {
          this.orderListnoshow = false
          this.orderListshow = true
        } else {
          this.orderListnoshow = true
          this.orderListshow = false
        }
      })


    },
    methods: {
      headleBackorder() {
        this.$emit('headleBackorder')
      },
      headerCopy(link) {
        this.copy(link)
      },
      copy(data) {
        let url = data
        let oInput = document.createElement('input')
        oInput.value = data
        document.body.appendChild(oInput)
        oInput.select() // 选择对象;
        document.execCommand('Copy') // 执行浏览器复制命令
        this.$toast({
          overlay: true,
          message: '复制成功',
          duration: 2000
        })
        oInput.remove()
      },

    }
  }
</script>
<style lang="scss">
  .about-container {
    box-sizing: border-box;
    overflow: hidden;

    .filter {
      position: fixed;
      top: 0;
      height: 50px;
      width: 100%;

    }

    .main {
      box-sizing: border-box;
      .mainlist {
        .bottom {
          // position: fixed;
          // bottom: 50px;
          font-weight: 400;
          text-align: center;
          font-size: 0.42667rem;
          color: #fc6f00;
          left: 0;
          right: 0;
          background: #fff;
          line-height: 36px;

          .tips {
            font-size: 14px;
            color: rgba(105, 105, 105, 1);
          }
        }

        .listmain {
          margin-bottom: 10px;

          .orderstatus {
            height: 65px;
            background: rgba(252, 214, 0, 1);
            font-size: 14px;
            line-height: 65px;
            padding-left: 16px;
            position: relative;
            .cross{
              position: absolute;
              right: 10px;
              top:20px;

            }
          }

          .order_address {
            display: flex;
            border-bottom: 6px solid #e6e6e6;
            padding: 15px 18px;
            box-sizing: border-box;

            .left {
              width: 30px;
              position: relative;

              img {
                width: 18px;
                position: absolute;
                top: 10px;
              }
            }

            .right {
              .info {
                display: flex;
                font-size: 14px;
                line-height: 20px;
                margin-bottom: 4px;
              }

              font-size: 12px;
            }
          }

          .order_main {
            .cakelist {
              display: flex;
              flex-wrap: wrap;
              justify-content: space-between;
              padding: 15px;

              li {
                flex: 1;
                width: 161px;
                min-width: 161px; // 加入这两个后每个item的宽度就生效了
                max-width: 161px; // 加入这两个后每个item的宽度就生效了
                height: 200px;
                background: rgba(255, 255, 255, 1);
                box-shadow: 0px 2px 4px 0px rgba(209, 209, 209, 0.5), 0px -2px 4px 0px rgba(224, 224, 224, 0.5);
                border-radius: 6px;
                overflow: hidden;
                margin-bottom: 22px;

                .cakeimg {
                  width: 161px;
                  height: 147px;
                }

                .cakename {
                  padding: 6px 12px;
                  display: block;
                  overflow: hidden;
                  height: 32px;
                  text-overflow: ellipsis;
                  display: -webkit-box; //作为弹性伸缩盒子模型显示。
                  -webkit-box-orient: vertical; //设置伸缩盒子的子元素排列方式--从上到下垂直排列
                  -webkit-line-clamp: 3; //显示的行
                }
              }
            }

            .order_info {
              box-sizing: border-box;
              font-size: 0.37333rem;
              width: 100%;

              .order-item {
                .title {
                  width: 80px;

                  &.odernum,
                  &.orderTime {
                    color: #6c6c6c;
                  }
                }

                display: flex;
                justify-content: space-between;
                border-bottom: 1px solid #f2f2f2;
                padding: 0.26667rem 0.42667rem;

                .ordernum_read {
                  color: #fc6f00;
                  font-size: 14px;
                  border-left: 1px solid #ccc;
                  padding-left: 8px;
                }
              }

              .line {
                height: 6px;
                background: #e6e6e6;
              }
            }
          }
        }

        .nodata {
          padding-top: 82px;

          img {
            width: 125px;
            height: 106px;
            margin: auto;
            display: block;
          }

          .tips {
            font-size: 16px;
            color: #767676;
            line-height: 22px;
            text-align: center;
          }
        }

        .bottomNodata {
          position: fixed;
          bottom: 50px;
          font-weight: 400;
          text-align: center;
          font-size: 0.42667rem;
          color: #fc6f00;
          left: 0;
          right: 0;
          background: #fff;
          line-height: 36px;
          margin-bottom: 5px;

          .tips {
            font-size: 14px;
            color: rgba(105, 105, 105, 1);
          }
        }

      }
    }

    .van-popup {
      background: transparent !important;
    }

    .logincont {
      left: 0;
      top: 0;
      right: 0;
      margin: 0;
      width: 302px;
      height: 172px;
      margin: 0 auto;
      line-height: 20px;
      // border-radius: 50%;
      border-radius: 10px;
      text-align: center;
      background-color: #fff;
      padding: 20px;

      .person_yzm {
        display: flex;
        justify-content: space-between;
        margin-bottom: 30px;

        span {
          font-size: 16px;
          color: #333;
        }
      }

      .person_loginitem {
        display: flex;
        justify-content: space-around;
        margin-bottom: 15px;

        .smscode {
          width: 200px;
          border: none;
          font-size: 14px;
          border-bottom: 1px solid #eee;
          color: #bbb;
          font-weight: 200;
        }

        .sendcode {
          line-height: 20px;
          border-radius: 3px;
          background-color: rgba(62, 151, 252, 1);
          color: rgba(255, 255, 255, 1);
          text-align: center;
          box-shadow: 0px 0px 6px 0px rgba(59, 48, 25, 0.31);
        }

      }

      .person_tip {
        font-size: 12px;
        font-weight: 200;
        color: #bbb;
        text-align: left;
        margin-bottom: 25px;
      }

      .person_sumbit {
        background-color: rgba(244, 197, 105, 1);
        color: rgba(255, 255, 255, 1);
        font-size: 14px;
        text-align: center;
        box-shadow: 0px 0px 6px 0px rgba(59, 48, 25, 0.31);
        width: 100px;
        height: 38px;
      }
    }
  }

</style>
